# This is a sample Python script.
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
import importlib
import os
import re
import threading


def import_module(file_name):
    if re.match('__pycache__', file_name):
        pass
    else:
        module = importlib.import_module('modules.' + file_name)
        module.app()


def app():
    filePath = r'./modules'
    file_list = os.listdir(filePath)

    try:
        for file in file_list:
            j = os.path.splitext(file)[0]
            p_id = threading.Thread(target=import_module, args=(j,))
            p_id.start()
    except:
        print("Error: unable to start thread")
    print('执行完毕')


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    app()

# See PyCharm help at https://www.jetbrains.com/help/pycharm/
